<?php

namespace App\Models\Factory;

use App\Models\AbsModelFactory;
use App\Models\Admin\AdminUser;
use App\Models\Orm\Delivery;
use App\Models\Orm\Loading;
use App\Models\Orm\Product;
use App\Models\Orm\Project;
use App\Models\Orm\Recommand;
use App\Models\Orm\Sms;
use App\Models\Orm\SmsNew;
use App\Models\Orm\Vip;
use Illuminate\Support\Facades\Log;



/**
 * 安稳号后台用户操作工厂方法
 * Class AdminFactory
 * @package App\Models\Factory
 */
class ProductFactory extends AbsModelFactory
{


    /**
     * 热门推荐中获取没有在热门推荐表中的产品id,name列表
     * @return mixed
     */
    public static function RecommendProducts()
    {
        $recommends = Recommand::select(['product_id'])->get()->toArray();
        $recommend_product_id = array_column($recommends,'product_id') ? : [];
        $list = Product::where('status','=',1)->whereNotIn('id',$recommend_product_id)->get()->toArray();
        $data = array_column($list,'name','id');
        return $data ? : [];
    }

    /**
     * 热门推荐中获取没有在热门推荐表中的产品id,name列表
     * @return mixed
     */
    public static function VipProducts()
    {
        $recommends = Vip::select(['product_id'])->get()->toArray();
        $recommend_product_id = array_column($recommends,'product_id') ? : [];
        $list = Product::where('status','=',1)->whereNotIn('id',$recommend_product_id)->get()->toArray();
        $data = array_column($list,'name','id');
        return $data ? : [];
    }


    public static function LoadingProducts()
    {
        $recommends = Loading::select(['product_id'])->get()->toArray();
        $recommend_product_id = array_column($recommends,'product_id') ? : [];
        $list = Product::where('status','=',1)->whereNotIn('id',$recommend_product_id)->get()->toArray();
        $data = array_column($list,'name','id');
        return $data ? : [];
    }



    public static function SmsProducts()
    {
        $recommends = Sms::select(['product_id'])->get()->toArray();
        $recommend_product_id = array_column($recommends,'product_id') ? : [];
        $list = Product::where('status','=',1)->whereNotIn('id',$recommend_product_id)->get()->toArray();
        $data = array_column($list,'name','id');
        return $data ? : [];
    }




    public static function SmsNewProducts()
    {
        $recommends = SmsNew::select(['product_id'])->get()->toArray();
        $recommend_product_id = array_column($recommends,'product_id') ? : [];
        $list = Product::where('status','=',1)->whereNotIn('id',$recommend_product_id)->get()->toArray();
        $data = array_column($list,'name','id');
        return $data ? : [];
    }



    public static function ProjectProducts()
    {
        $recommends = Project::select(['product_id'])->get()->toArray();
        $recommend_product_id = array_column($recommends,'product_id') ? : [];
        $list = Product::where('status','=',1)->whereNotIn('id',$recommend_product_id)->get()->toArray();
        $data = array_column($list,'name','id');
        return $data ? : [];
    }


}